<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>一条龙保健系统</title>
  <link rel="stylesheet" href="/static/css/style.css">
  <link rel="stylesheet" href="/static/plugins/easyui/themes/bootstrap/easyui.css">
  <link rel="stylesheet" href="/static/plugins/easyui/themes/icon.css">

  <script type="text/javascript" src="/static/plugins/easyui/jquery.min.js"></script>
  <script type="text/javascript" src="/static/plugins/easyui/jquery.easyui.min.js"></script>

  <!--引入中文包-->
  <script type="text/javascript" src="/static/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>


    <script type="text/javascript">

        //登录方法
        function login(){
          //登录方法,发送请求
          $.post('/login.do',$("#myLogin").serialize(),function(data){
              if (data.success) {
                  //如果登录成功跳转到主页
                  window.parent.location.href="/index.do";
              }else{
                  //登录失败提示信息
                  alert(data.msg);
              }
          },'json')
        }






      $(function(){
         $("#loginButton").click(function(){
             login();
         });

          //注册用户弹出框初始化
          $('#register').dialog({
              title:"注册用户",
              closed:true,
              width:360,
              height:450,
              collapsible:true,
              minimizable:true,
              maximizable:true,
              buttons:'#btn',
              onClose:function () {
                  //关闭的同时清除表单数据
                  $("#emp_form").form('clear');
              }
          });


          //注册按钮绑定点击事件
          $("#registerButton").click(function () {
              //打开注册用户弹出框
              $('#register').dialog('open')
          });

          //保存和取消操作调用的方法
          var methodObj = {
              //保存操作
              saved:function (){
              //提交表单
              $("#emp_form").form("submit",{
                  url:'/saveOrUpdate.do',
                  success:function (data) {
                      console.log(data);
                      //回调函数:data表示返回数据解析为json
                      data = $.parseJSON(data);
                      if (data.success) {
                          //如果返回结果成功__弹出窗口提示
                          $.messager.alert('温馨提示','保存成功','info',function () {
                              methodObj.cancel();
                              //保存成功就跳转回登录界面
                              window.location.href="/login.jsp";
                          })
                      }else {
                          //如果保存失败,则弹出窗口提示
                          $.messager.alert('温馨提示',data.msg,'error');
                      }
                  }
              });
          },

          //取消操作,关闭注册用户弹出框
              cancel:function (){
              //关闭弹出框:
              $("#register").dialog('close');

          }



          }





          //统一绑定事件:
          $("a[data-cmd]").click(function () {
              var methodname = $(this).data("cmd");
              //动态获取调用方法名字,调用方法;
              methodObj[methodname]();
          })
      });
    </script>


</head>
<body>
<%--特效--%>
<script type="text/javascript" color="225,225,225" zindex="-1" opacity="1" count="200" src="/static/js/canvas-nest.min.js"></script>

<div class="container" >
    <div  class="login" zIndex="1">
        <h1>用户登录</h1>
        <form  id="myLogin" method="post">
            <p><input type="text" name="username" value="admin" placeholder="账号"></p>
            <p><input type="password" name="password" value="1" placeholder="密码"></p>
            <p class="submit">
                <input id="loginButton" type="button" value="登录">
                <input id="registerButton" type="button" value="注册">
            </p>
        </form>
    </div>
</div>





<%--保存和取消按钮--%>
<div id="btn">
    <a class="easyui-linkbutton" iconCls="icon-add" data-options="plain:true" data-cmd="saved"/>保存</a>
    <a class="easyui-linkbutton" iconCls="icon-edit" data-options="plain:true"  data-cmd="cancel">取消</a>
</div>



<%--弹出窗口--%>
<div id="register">
    <!--创建表单-->
    <form id="emp_form" method="post">
        <table align="center" style="margin-top:15px">
            <input type="hidden" name="id" id="empId"/>
            <tr>
                <td align="center">用户名:</td>
                <td><input  name="username" class="easyui-textbox"  prompt="请输入姓名" iconCls="icon-man"
                            invalidMessage="用户名已经存在"
                            validType="remote['/validate.do','username']"
                /></td>
            </tr>
            <tr>
                <td align="center">真实姓名:</td>
                <td><input name="realname" class="easyui-textbox"  prompt="请输入真实姓名" iconCls="icon-man"/></td>
            </tr>
            <tr id="psw">
                <td align="center">密码:</td>
                <td><input name="password" type="password" class="easyui-textbox" /></td>
            </tr>
            <tr>
                <td align="center">电话:</td>
                <td><input name="tel" class="easyui-textbox" prompt="请输入电话" /></td>
            </tr>

            <input type="hidden" name="dept.id" value="100" />
            <tr>
                <td align="center">邮箱:</td>
                <td><input name="email" class="easyui-textbox" prompt="请输入邮箱" iconCls="icon-email"
                           validType="email" /></td>
            </tr>


            <tr>
                <td align="center">超级管理员:</td>
                <td><input name="admin" class="easyui-combobox" prompt="是否是超级管理员"
                           data-options="panelHeight:'auto',textField:'text',valueField:'value',
                    data:[{text:'是',value:'1'},{text:'否',value:'0'}]"/></td>
            </tr>


        </table>
    </form>
</div>

<div style="text-align:center;" class="login-help">
    <p>大  宝  剑</p>
</div>



</body>
</html>
